<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      margin:0;
    }
    header {
      height: 160px;
      position: relative;
      overflow:hidden;
      --percentage: 0.5;
    }
    header .view, header .tree {
      position: absolute;
      top:0;
      left:0;
      right:0;
      bottom:0;
      display: flex;
      justify-content: center;
      align-items:center;
    }
    header img, header video {
      position: absolute;
      display: block;
      width: 120%;
      height: 100%;
      object-fit: cover;
    }
    header .morning {
      z-index: 20;
      opacity: calc( 1 - (var(--percentage) - 0.25) / 0.25 );
    }
    header .afternoon {
      z-index: 10;
      opacity: calc( 1 - (var(--percentage) - 0.5) / 0.5 );
    }
    header .view {
      transform: translateX(calc(var(--percentage)* -60px));
    }
    header .tree {
      transform: translateX(calc(var(--percentage)* -30px));
      filter: blur(2px);
    }
    header.moving .view,
    header.moving .tree,
    header.moving .morning,
    header.moving .afternoon {
      transition: .2s all ease-in;
    }

    header.moving .view,
    header.moving .tree,
    header.moving .morning,
    header.moving .afternoon {
      transition:none;
    }
    header .window-snow {
      opacity: calc((var(--percentage) - 0.9) / 0.1);
    }

    .logo {
      position: absolute;
      top:80px;
      left:138px;
      width: 170px;
      height: 70px;
    }
    .logo img {
      width: 100%;
      height: 100%;
      vertical-align: middle;
    }
  </style>
</head>
<body>
  <header>
    
    <div class="view">
      <img class="morning" src="./image/img_1.jpg" alt="早晨">
      <img class="afternoon" src="./image/img_2.jpg" alt="下午">
      <video class="evening" autoplay loop muted >
        <source src="./video/video.webm">
      </video>
      <img class="window-snow" src="./image/window_snow.png" alt="">
    </div>
    <div class="tree">
      <img class="morning" src="./image/tree_1.png" alt="">
      <img class="afternoon" src="./image/tree_2.png" alt="">
      <img class="evening" src="./image/tree_3.png" alt="">
    </div>
    <a class="logo" href="https://www.bilibili.com/">
      <img src="./image/logo.png" alt="LOGO">
    </a>
  </header>
</body>
<script>
  const header = document.querySelector('header')
  let startPoint 
  header.addEventListener('mouseover', e =>{
    startPoint = e.clientX
    header.classList.add('moving')
  })
  
  header.addEventListener('mouseout', e =>{
    header.style.setProperty('--percentage', 0.5)
    header.classList.remove('moving')
  })
  header.addEventListener('mousemove', e =>{
    let percentage = (e.clientX - startPoint ) / window.outerWidth + 0.5
    header.style.setProperty('--percentage',percentage)
  })
</script>
</html>